<!-- 父组件 -->
<template>
  <div>
    <h1>父组件</h1>
    <button @click="showChild">点击显示子组件</button>
    <child ref="child"></child>
  </div>
</template>

<script>
  import Child from "./Child";
  export default {
    name: 'Parent',
    components: { Child },
    methods: {
      showChild () {
        const child = this.$refs.child;   // 获取子组件的实例
        console.log(child);
        child.show();
      }
    }
  }
</script>

<style scoped>

</style>
